home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / TEXTCLOS.C < prev    next >
Text File  |  1992-05-14  |  2KB  |  67 lines

  1. /************************************************************************************/
  2. /*    TextCloseProc                                                                    */
  3. /************************************************************************************/
  4.  
  5. #include "MyHeaders.h"
  6.  
  7. int TextCloseProc ()
  8. {
  9.     int        TCRetCode = 0;
  10.     int        item;
  11.  
  12.     if (windTbl[windSub].windPtr == 0)                    /* if window already closed    */
  13.         goto ENDING;                                    /* skip this whole thing    */
  14.  
  15.     if (windTbl[windSub].windTEChanged == TRUE)
  16.         {
  17.         GetWTitle(windTbl[windSub].windPtr, &workStr255);
  18.         ParamText (&workStr255,"","","");                    /* set name                */
  19.         PlaceAlert (139);                                    /* position the alert    */
  20.         item = CautionAlert (139, NIL);                        /* show the alert        */
  21.         switch (item)
  22.             {
  23.             case (cancel):
  24.                 TCRetCode = 2;                            /* indicate cancel            */
  25.                 goto ENDING;
  26.             break;
  27.             
  28.             case (ok):                                    /* for "save"                */
  29.                 WorkRetCode = FileSaveProc (FALSE);        /* save, then fall thru        */
  30.                 if (WorkRetCode == 2)                    /* if it was a cancel        */
  31.                     {
  32.                     TCRetCode = 2;
  33.                     goto ENDING;
  34.                     }
  35.                 if (WorkRetCode != noErr)                /* if error in save            */
  36.                     {
  37.                     GetWTitle(windTbl[windSub].windPtr, &workStr255);
  38.                     ParamText (&workStr255,"","","");
  39.                     PlaceAlert (138);                        /* position the alert    */
  40.                     StopAlert (138, NIL);                    /* show the alert        */
  41.                     TCRetCode = 1;                            /* set bad return code    */
  42.                     goto ENDING;                            /* get out                */
  43.                     }
  44.             break;
  45.             }
  46.         }
  47.  
  48.                                     /*for no save or fall thru from save    */
  49.         if (windTbl[windSub].windPathRefNum != 0)    
  50.             {
  51.             workRC = FSClose (windTbl[windSub].windPathRefNum);    /* close    */
  52.             if (workRC != noErr)                        /* if bad close        */
  53.                 {
  54.                 TCRetCode = 1;                            /* set bad return    */
  55.                 goto ENDING;                            /* get out            */
  56.                 }
  57.             }
  58.         windTbl[windSub].windPathRefNum = 0;        /* indicate file closed    */
  59.         CloseWindow(windTbl[windSub].windPtr);        /* close the window        */
  60.         windTbl[windSub].windPtr = 0;                /* indicate closed        */
  61.         windTbl[windSub].windTEChanged = FALSE;        /* initialize            */
  62.  
  63.  
  64. ENDING:
  65.     return    TCRetCode;
  66.  
  67. }